﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using QuanLyBongDa.HeThongGiaoDien;
using QuanLyBongDa.HeThongLuuTru;
using QuanLyBongDa.HeThongXuLy;

namespace QuanLyBongDa.HeThongLuuTru
{
    class HoSoDoiBong
    {
        public static bool ThemHoSoDoiBong(HoSoDoiBongDTO hs)
        {
            try
            {
                string sql = "insert into HOSODOIBONG(TenDoiBong, TenSanNha, MaSanNha, ThanhLap, ChuTich, HuanLuanVien) values ('" + hs.TenDoiBong + "','" + hs.TenSanNha + "','" + hs.MaSanNha + "','" + hs.ThanhLap + "','" + hs.ChuTich + "','" + hs.HuanLuanVien + "')";
                DataAccess.ExecNonQuery(sql);
                return true;

            }
            catch (Exception)
            {
                //MessageBox.Show(ex.ToString());
                return false;
            }
        }
        public static DataTable BangHoSoDoiBong()
        {
            string sql = "SELECT* FROM HOSODOIBONG";
            return DataAccess.ExecQuery(sql);
        }

        public static bool XoaHoSoDoiBong(HoSoDoiBongDTO hs)
        {
            try
            {
                string sql = "Delete from HOSODOIBONG where MaDoiBong = " + hs.MaDoiBong;
                DataAccess.ExecNonQuery(sql);
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }

        public static bool SuaHoSoDoiBong(HoSoDoiBongDTO hs)
        {
            try
            {
                string sql = "Update HOSODOIBONG set TenDoiBong = '" + hs.TenDoiBong + "',TenSanNha = '" + hs.TenSanNha + "',MaSanNha = '" + hs.MaSanNha + "',ThanhLap = '" + hs.ThanhLap + "',ChuTich = '" + hs.ChuTich + "',HuanLuanVien = '" + hs.HuanLuanVien + "' where MaDoiBong =" + hs.MaDoiBong;
                DataAccess.ExecNonQuery(sql);
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
    }
}
